{% extends "events/base.html" %}
{% load i18n %}
{% load comments %}

{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% load adminmedia %}{% admin_media_prefix %}css/dashboard.css" />{% endblock %}

{% block coltype %}colMS{% endblock %}

{% block bodyclass %}dashboard{% endblock %}

{% block breadcrumbs %}
	{% if not is_popup %}
		<div class="breadcrumbs">
		     <a href="../../">Home</a> &rsaquo;
		     <a href="../">Event Manager</a> &rsaquo;
		     {{ event.Name }}
		</div>
	{% endif %}
{% endblock %}

{% block content %}
	{% if isPlanner%}
		<form action="/events/{{event.id}}/edit/" method="POST">
	{% endif %}
{% csrf_token %}
	<fieldset class="module aligned {{ fieldset.classes }}">
	        {% for field in form %}
	        <div class="form-row{% if field.errors %} errors{% endif %} {{ field.field.name }}">
	            {{ field.errors }}
	               {% if field.is_checkbox %}
	                   {{ field.field }}{{ field.label_tag }}
	               {% else %}
	                   {{ field.label_tag }}
	                   {% if field.is_readonly %}
	                       <p>{{ field.contents }}</p>
	                   {% else %}
	                       {{ field }}
	                   {% endif %}
	               {% endif %}
	               {% if field.help_text %}
	                   <p class="help">{{ field.help_text|safe }}</p>
	               {% endif %}
	        </div>
	    {% endfor %}
	</fieldset>
	{% if isPlanner%}
			 <div class="submit-row">
			 		<p class="deletelink-box"><a href="/events/{{event.id}}/delete" class="deletelink">Delete</a></p>
		 			<input type="submit" value="Update" class="default" name="_save" {{ onclick_attrib }}/>
		 			<label>&nbsp;</label><input type="button" value="Cancel" ONCLICK="window.location.href='{% url ocms.eventmanager.views.index %}'"/>
			</div>
		</form>
	{% endif %}
{% endblock %}


{% block sidebar %}
<div id="content-related">
    <div class="module" id="event_status-module">
		<h2> Status </h2>
			Event Type: {{event_type}}<br/>
			Submitted: {{event.date_created|date:"Y/m/d H:i"}}<br/>
			Event Status: {{event.get_event_status_display}}<br/>
			Event Cost: ${{event.get_cost|floatformat:2 }}<br/>
			Approval Status: {{event.get_approval_status_display}}<br/>
			{% if event.approval_status == 'H'%}<p style="color:red;">Held by: {{event.approval_status_user}} on {{event.approval_date|date:"Y/m/d"}}</p>{%endif%}
    </div>
    <br />
    <div class="module" id="event_votes-module">
		<h2> Voting </h2>
			{% if votes %}
				<ul>
					{% for vote in votes %}
						<li>{{vote.user}} voted "{{vote.get_vote_display}}"</li>
					{% endfor %}
				</ul>
			{% else %}
				No votes have been entered.
			{% endif %}
    </div>
	{% if can_vote %}
		<br />
	    <div class="module" id="vote-module">
			<h2> Vote </h2>
			{% if user_vote %}
				{% for vote in user_vote %}
					You voted "{{vote.get_vote_display}}" on {{vote.vote_date|date:"Y/m/d H:i"}}					
				{% endfor %}
			{% else %}
				<form action="/events/{{ event.id }}/vote/" method="post">
					{% csrf_token %}
					<ul class="actionlist">
						{% for opt in vote_opts %}
						<li>
					    	<input type="radio" name="choice" id="choice{{forloop.counter}}" value="{{opt|first}}" />
					  		<label for="choice{{forloop.counter}}">{{opt|last}}</label> 
					  	</li>
						{% endfor %}
						<li><input type="submit" value="Vote" /></li></form>
						<form action="/events/{{ event.id }}/hold/" method="post">
							{% csrf_token %}
							<li><input type="submit" value="{% if event.approval_status == 'H' %}Unhold{%else%}Hold{%endif%}" /></li>
						</form>
					</ul>
			
			{% endif %}
	    </div>
	    <br />
	{% endif %}
	    <div class="module" id="event_comments-module">
		<h2> Comments </h2>
		{% if user.is_authenticated %}
			{% get_comment_form for event as form%}
	
			<form action="{% comment_form_target %}" method="post">{% csrf_token %}
			  <input type="hidden" name="next" value="/events/{{ event.id }}/" />
			  {% for field in form %}
			  	{% if field.is_hidden %}
			      {{ field }}
			    {% else %}
				    {% if field.name != "name" and field.name != "email" and field.name != "url" %}
						{% if field.errors %}{{ field.errors }}{% endif %}
						<p
							{% if field.errors %} class="error"{% endif %}
							{% ifequal field.name "honeypot" %} style="display:none;"{% endifequal %}>
							{% if field.name == "comment" %}
								<textarea id="id_{{field.name}}" name="{{field.name}}" COLS=25 ROWS=5></textarea>
							{% else %}
								{{ field.label_tag }} {{ field }}
							{% endif %}
						</p>
						{% endif %}
					{% endif %}
		  {% endfor %}
	  <p class="submit">
	    <input type="submit" name="post" class="submit-post" value="{% trans "Post" %}" />
	  </p>
	</form>
{%endif%}
		{% get_comment_count for event as comment_count %}
		{% if comment_count > 0 %}
			{% get_comment_list for event as comment_list %}
			<dl id="comments">
			{% for comment in comment_list %}
			    {% if not comment.is_removed %}
				    <dt id="{{comment.id}}">
				        {{comment.user_name}} said: <br>
				        ({{comment.submit_date|date:"SHORT_DATE_FORMAT"}})
				    </dt>
				    <dd>
				        <p>{{comment.comment}}</p>
				    </dd>
				{%endif%}
			{% endfor %}
			</dl>
		{%else%}
			No comments
		{%endif%}
		
    </div>
</div>
{% endblock %}
